(*
 _Environment.pas - Delphi File implementation
*)
unit _Environment;

interface
  uses SysUtils, Windows;

  type
    envNames = array of string;
    Environment = class (TObject)
      public
        constructor new (); overload;
        destructor Destroy; override;
        function getValue (name : string) : string;
        function getNames () : envNames;
    end;

implementation

  constructor Environment.new ();
  begin
  end;

  destructor Environment.Destroy ();
  begin
    inherited Destroy;
  end;

  function Environment.getValue (name : string) : string;
  begin
    result := GetEnvironmentVariable(name);
  end;

  function Environment.getNames () : envNames;
  var
    temp, envName : PChar;
    names : envNames;
    index : Integer;
  begin
    envName := GetEnvironmentStrings ();
    temp := envName;
    index := 0;
    while temp^ <> #0 do
      begin
        setlength(names, index+1);
        names[index] := temp;
        inc(envName, lStrLen(envName) + 1);
//writeln (envName);
        index := index + 1;
      end;
    FreeEnvironmentStrings(envName);
  end;

end.
